package com.mybatis;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/**
 * @author cyt
 * @create 2020-03-16 10:43
 */
@SpringBootApplication
@EnableEurekaClient // 注册服务
@EnableDiscoveryClient // 发现服务
@EnableCircuitBreaker // 开启熔断
public class Appilcation_Hystrix {
    public static void main(String[] args) {
        SpringApplication.run(Appilcation_Hystrix.class, args);
    }

    // 配置对开启熔断方法的监控，
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet() {
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        registrationBean.addUrlMappings("/actuator/hystrix.stream");
        return registrationBean;
    }
}
